package dmmm.shemes;


import java.awt.Point;
import java.util.ArrayList;

import dmmm.components.*;
import dmmm.gui.GuiLabel;
import dmmm.gui.GuiLine;
import dmmm.gui.GuiScheme;

public class Bus1 {
    
    private static BUS IBUS1, IBUS2;
    private static BUS ABUS, DBUS;
    private static BUS NOTRDBUS, NOTWRBUS, NOTFCBUS;
    private static TSB TSBMOST1_2, TSBMOST2_1, TSBMDRout2, TSBeMAR, TSBeMDR, TSBrdCPU, TSBwrCPU, TSBDWout1, TSB1;
    private static IntToInt IBUS2low;
    private static MP MX1;
    private static AND AND1, AND2;
    private static OR OR1;
    private static REG MAR, MDR, DWH, DWL;
    private static NOT NOT1, NOT2, NOT3, NOT4;
    private static BoolsToInt DW;
    private static IntToBools DWHbools, DWLbools;
    //brojaci koliko ima prikacenih listenera na magistralu
    private static int abusi = 0, dbusi = 0, ibus1i = 0, ibus2i = 0, rdbusi = 0, wrbusi = 0, fcbusi = 0;
    private static GuiScheme gui;
    
    public static GuiScheme getGui() {
        return gui;
    }
    
    public static void init() {

        // neka bude da ih je 16 nakaceno na magistralu
        IBUS1 = new BUS(16, 1, "IBUS1");
        IBUS1.getOut(0).setNumOfLines(16);
        IBUS2 = new BUS(16, 1, "IBUS2");
        IBUS2.getOut(0).setNumOfLines(16);
        
        ABUS = new BUS(16, 1, "ABUS");
        ABUS.getOut(0).setNumOfLines(16);
        
        DBUS = new BUS(16, 1, "DBUS");
        DBUS.getOut(0).setNumOfLines(8);
        
        NOTRDBUS = new BUS(8, 1, "NOTRDBUS");
        NOTRDBUS.getOut(0).setIsBool();
        NOTWRBUS = new BUS(8, 1, "NOTWRBUS");
        NOTWRBUS.getOut(0).setIsBool();
        NOTFCBUS = new BUS(8, 1, "NOTFCBUS");
        NOTFCBUS.getOut(0).setIsBool();
        
        TSBMOST1_2 = new TSB();
        TSBMOST1_2.getOut(0).setNumOfLines(16);
        TSBMOST1_2.setIsMostTSB(true);
        
        TSBMOST2_1 = new TSB();
        TSBMOST2_1.getOut(0).setNumOfLines(16);
        TSBMOST2_1.setIsMostTSB(true);
        
        TSBMDRout2 = new TSB();
        TSBMDRout2.getOut(0).setNumOfLines(8);
        
        TSBeMAR = new TSB();
        TSBeMAR.getOut(0).setNumOfLines(16);
        
        TSBeMDR = new TSB();
        TSBeMDR.getOut(0).setNumOfLines(8);
        
        TSBrdCPU = new TSB();
        TSBrdCPU.getOut(0).setNumOfLines(1);
        TSBrdCPU.getOut(0).setIsBool();
        
        TSBwrCPU = new TSB();
        TSBwrCPU.getOut(0).setNumOfLines(1);
        TSBwrCPU.getOut(0).setIsBool();
        
        TSBDWout1 = new TSB();
        TSBDWout1.getOut(0).setNumOfLines(16);
        
        IBUS2low = new IntToInt(16, 8, false, false);//sa 16 na 8 linija za MDR i DW

        MX1 = new MP(2);
        MX1.getOut(0).setIsInt();
        MX1.getOut(0).setNumOfLines(8);
        
        AND1 = new AND();
        AND2 = new AND();
        OR1 = new OR();
        
        MAR = new REG(1, "MAR");
        MAR.getOut(0).setIsInt();
        MAR.getOut(0).setNumOfLines(16);
        
        MDR = new REG(1, "MDR");
        MDR.getOut(0).setIsInt();
        MDR.getOut(0).setNumOfLines(8);
        
        DWH = new REG(1, "DWH");
        DWH.getOut(0).setIsInt();
        DWH.getOut(0).setNumOfLines(8);
        DWL = new REG(1, "DWL");
        DWL.getOut(0).setIsInt();
        DWL.getOut(0).setNumOfLines(8);
        
        TSB1 = new TSB();
        TSB1.getOut(0).setNumOfLines(1);
        TSB1.getOut(0).setIsBool();
        NOT1 = new NOT();
        
        NOT2 = new NOT();
        NOT3 = new NOT();
        NOT4 = new NOT();
        
        DW = new BoolsToInt(16, 16);
        DWHbools = new IntToBools(8, 8);
        DWLbools = new IntToBools(8, 8);
    }
    
    public static void connect() {
        
        TSBMOST1_2.setInputPin(0, IBUS1.getOut(0));
        TSBMOST1_2.setCtrl(Oper1.MOST1_2());
        Bus1.addOnIBUS2(TSBMOST1_2.getOut(0));
        
        TSBMOST2_1.setInputPin(0, IBUS2.getOut(0));
        TSBMOST2_1.setCtrl(Oper1.MOST2_1());
        Bus1.addOnIBUS1(TSBMOST2_1.getOut(0));
        
        IBUS2low.setInputPin(0, IBUS2.getOut(0));
        
        MX1.setInputPin(0, DBUS.getOut(0));
        MX1.setInputPin(1, IBUS2.getOut(0));
        MX1.setCtrl(0, Oper1.mxMDR());
        
        TSB1.setInputPin(0, Bus1.NOTFCBUS());
        NOT1.setInputPin(0, TSB1.getOut(0));
        
        AND1.setInputPin(0, Oper1.rdCPU());
        AND1.setInputPin(1, NOT1.getOut(0));
        
        OR1.setInputPin(0, Oper1.ldMDR());
        OR1.setInputPin(1, AND1.getOut(0));
        
        MDR.setInputPin(0, MX1.getOut(0));
        MDR.setPinLd(OR1.getOut(0));
        
        TSBMDRout2.setInputPin(0, MDR.getOut(0));
        TSBMDRout2.setCtrl(Oper1.MDRout2());
        Bus1.addOnIBUS2(TSBMDRout2.getOut(0));
        
        TSBeMDR.setInputPin(0, MDR.getOut(0));
        TSBeMDR.setCtrl(Oper1.eMDR());
        Bus1.addOnDBUS(TSBeMDR.getOut(0));
        
        MAR.setInputPin(0, IBUS1.getOut(0));
        MAR.setPinLd(Oper1.ldMAR());
        MAR.setPinInc(Oper1.incMAR());
        
        TSBeMAR.setInputPin(0, MAR.getOut(0));
        TSBeMAR.setCtrl(Oper1.eMAR());
        Bus1.addOnABUS(TSBeMAR.getOut(0));
        
        TSBrdCPU.setInputPin(0, new Pin(true));
        TSBrdCPU.setCtrl(Oper1.rdCPU());
        NOT2.setInputPin(0, TSBrdCPU.getOut(0));
        Bus1.addOnNOTRDBUS(NOT2.getOut(0));
        
        TSBwrCPU.setInputPin(0, new Pin(true));
        TSBwrCPU.setCtrl(Oper1.wrCPU());
        NOT3.setInputPin(0, TSBwrCPU.getOut(0));
        Bus1.addOnNOTWRBUS(NOT3.getOut(0));
        
        NOT4.setInputPin(0, Oper1.eMAR());
        //AND2.setInputPin(0, Oper1.hreq());
        AND2.setInputPin(0, new Pin(false));
        AND2.setInputPin(1, NOT4.getOut(0));
        
        DWH.setInputPin(0, IBUS2low.getOut(0));
        DWH.setPinLd(Oper1.ldDWH());
        
        DWL.setInputPin(0, IBUS2low.getOut(0));
        DWL.setPinLd(Oper1.ldDWL());
        
        DWLbools.setInputPin(0, DWL.getOut(0));
        DWHbools.setInputPin(0, DWH.getOut(0));
        
        for (int i = 0; i < 8; i++) {
            DW.setInputPin(i, DWLbools.getOut(i));
            DW.setInputPin(8 + i, DWHbools.getOut(i));
            
        }
        
        TSBDWout1.setInputPin(0, DW.getOut(0));
        TSBDWout1.setCtrl(Oper1.DWout1());
        Bus1.addOnIBUS1(TSBDWout1.getOut(0));
        
    }
    
    public static void gui() {
        GuiLine line; // Pomocna promenljiva
        gui = new GuiScheme("dmmm/dmmm/images/Bus1.png");
        
        ArrayList<ArrayList<Point>> sections;
        ArrayList<Point> points;
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(63, 26));
        points.add(new Point(63, 370));
        sections.add(points);
        points = new ArrayList<Point>();
        points.add(new Point(65, 26));
        points.add(new Point(65, 370));
        sections.add(points);
        line = new GuiLine(sections, Bus1.IBUS1());
        gui.addLine(line);
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(619, 26));
        points.add(new Point(619, 370));
        points.add(new Point(621, 26));
        points.add(new Point(621, 370));
        sections.add(points);
        line = new GuiLine(sections, Bus1.IBUS2());
        gui.addLine(line);
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(62, 494));
        points.add(new Point(62, 710));
        sections.add(points);
        points = new ArrayList<Point>();
        points.add(new Point(64, 494));
        points.add(new Point(64, 710));
        sections.add(points);
        line = new GuiLine(sections, Bus1.IBUS1());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(619, 494));
        points.add(new Point(619, 710));
        sections.add(points);
        points = new ArrayList<Point>();
        points.add(new Point(621, 494));
        points.add(new Point(621, 710));
        sections.add(points);
        line = new GuiLine(sections, Bus1.IBUS2());
        gui.addLine(line);
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(65, 67));
        points.add(new Point(521, 67));
        sections.add(points);
        line = new GuiLine(sections, Bus1.IBUS1());
        gui.addLine(line);
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(533, 73));
        points.add(new Point(533, 79));
        sections.add(points);
        line = new GuiLine(sections, Oper1.MOST1_2());
        gui.addLine(line);
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(545, 67));
        points.add(new Point(618, 67));
        sections.add(points);
        line = new GuiLine(sections, TSBMOST1_2.getOut(0));
        gui.addLine(line);
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(65, 111));
        points.add(new Point(148, 111));
        sections.add(points);
        line = new GuiLine(sections, TSBMOST2_1.getOut(0));
        gui.addLine(line);
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(159, 117));
        points.add(new Point(159, 122));
        sections.add(points);
        line = new GuiLine(sections, Oper1.MOST2_1());
        gui.addLine(line);
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(171, 111));
        points.add(new Point(618, 111));
        sections.add(points);
        line = new GuiLine(sections, Bus1.IBUS2());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(65, 190));
        points.add(new Point(233, 190));
        points.add(new Point(233, 217));
        sections.add(points);
        line = new GuiLine(sections, Bus1.IBUS1());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(150, 228));
        points.add(new Point(156, 228));
        sections.add(points);
        line = new GuiLine(sections, Oper1.ldMAR());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(150, 247));
        points.add(new Point(156, 247));
        sections.add(points);
        line = new GuiLine(sections, Oper1.incMAR());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(309, 237));
        points.add(new Point(318, 237));
        sections.add(points);
        line = new GuiLine(sections, LogicalComponent.getCPUCLK());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(233, 257));
        points.add(new Point(233, 359));
        sections.add(points);
        line = new GuiLine(sections, MAR.getOut(0));
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(221, 371));
        points.add(new Point(228, 371));
        sections.add(points);
        line = new GuiLine(sections, Oper1.eMAR());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(233, 383));
        points.add(new Point(233, 400));
        sections.add(points);
        line = new GuiLine(sections, TSBeMAR.getOut(0));
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(495, 131));
        points.add(new Point(495, 151));
        sections.add(points);
        line = new GuiLine(sections, Bus1.DBUS());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(618, 131));
        points.add(new Point(514, 131));
        points.add(new Point(514, 151));
        sections.add(points);
        line = new GuiLine(sections, Bus1.IBUS2());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(541, 171));
        points.add(new Point(534, 171));
        sections.add(points);
        line = new GuiLine(sections, Oper1.mxMDR());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(505, 191));
        points.add(new Point(505, 217));
        sections.add(points);
        line = new GuiLine(sections, MX1.getOut(0));
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(373, 302));
        points.add(new Point(381, 302));
        sections.add(points);
        line = new GuiLine(sections, Bus1.NOTFCBUS());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(410, 303));
        points.add(new Point(416, 303));
        points.add(new Point(416, 275));
        points.add(new Point(354, 275));
        points.add(new Point(354, 249));
        points.add(new Point(360, 249));
        sections.add(points);
        line = new GuiLine(sections, Bus1.NOT1.getOut(0));
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(354, 207));
        points.add(new Point(354, 237));
        points.add(new Point(360, 237));
        sections.add(points);
        line = new GuiLine(sections, Oper1.rdCPU());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(385, 243));
        points.add(new Point(400, 243));
        points.add(new Point(392, 243));
        points.add(new Point(392, 250));
        sections.add(points);
        line = new GuiLine(sections, AND1.getOut(0));
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(392, 207));
        points.add(new Point(392, 232));
        points.add(new Point(400, 232));
        sections.add(points);
        line = new GuiLine(sections, Oper1.ldMDR());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(423, 237));
        points.add(new Point(428, 237));
        sections.add(points);
        line = new GuiLine(sections, OR1.getOut(0));
        gui.addLine(line);
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(581, 237));
        points.add(new Point(588, 237));
        sections.add(points);
        line = new GuiLine(sections, LogicalComponent.getCPUCLK());
        gui.addLine(line);
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(505, 257));
        points.add(new Point(505, 303));
        points.add(new Point(521, 303));
        sections.add(points);
        points = new ArrayList<Point>();
        points.add(new Point(505, 303));
        points.add(new Point(505, 359));
        sections.add(points);
        line = new GuiLine(sections, MDR.getOut(0));
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(533, 309));
        points.add(new Point(533, 315));
        sections.add(points);
        line = new GuiLine(sections, Oper1.MDRout2());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(546, 303));
        points.add(new Point(619, 303));
        sections.add(points);
        line = new GuiLine(sections, TSBMDRout2.getOut(0));
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(494, 371));
        points.add(new Point(499, 371));
        sections.add(points);
        line = new GuiLine(sections, Oper1.eMDR());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(505, 383));
        points.add(new Point(505, 400));
        sections.add(points);
        line = new GuiLine(sections, TSBeMDR.getOut(0));
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(148, 453));
        points.add(new Point(158, 453));
        sections.add(points);
        line = new GuiLine(sections, new Pin(true));
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(170, 459));
        points.add(new Point(170, 464));
        sections.add(points);
        line = new GuiLine(sections, Oper1.rdCPU());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(187, 453));
        points.add(new Point(193, 453));
        sections.add(points);
        line = new GuiLine(sections, NOT2.getOut(0));
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(297, 453));
        points.add(new Point(307, 453));
        sections.add(points);
        line = new GuiLine(sections, new Pin(true));
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(320, 458));
        points.add(new Point(320, 464));
        sections.add(points);
        line = new GuiLine(sections, Oper1.wrCPU());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(337, 453));
        points.add(new Point(342, 453));
        sections.add(points);
        line = new GuiLine(sections, NOT3.getOut(0));
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(480, 447));
        points.add(new Point(491, 447));
        sections.add(points);
        line = new GuiLine(sections, new Pin(false));
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(480, 458));
        points.add(new Point(486, 458));
        sections.add(points);
        line = new GuiLine(sections, Oper1.eMAR());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(516, 453));
        points.add(new Point(522, 453));
        sections.add(points);
        line = new GuiLine(sections, AND2.getOut(0));
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(618, 547));
        points.add(new Point(280, 547));
        points.add(new Point(280, 565));
        sections.add(points);
        points = new ArrayList<Point>();
        points.add(new Point(505, 548));
        points.add(new Point(505, 565));
        sections.add(points);
        line = new GuiLine(sections, IBUS2low.getOut(0));
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(197, 575));
        points.add(new Point(203, 575));
        sections.add(points);
        line = new GuiLine(sections, LogicalComponent.getCPUCLK());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(197, 594));
        points.add(new Point(203, 594));
        sections.add(points);
        line = new GuiLine(sections, Oper1.ldDWH());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(280, 605));
        points.add(new Point(280, 623));
        sections.add(points);
        line = new GuiLine(sections, DWH.getOut(0));
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(422, 575));
        points.add(new Point(428, 575));
        sections.add(points);
        line = new GuiLine(sections, LogicalComponent.getCPUCLK());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(422, 594));
        points.add(new Point(428, 594));
        sections.add(points);
        line = new GuiLine(sections, Oper1.ldDWL());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(505, 605));
        points.add(new Point(505, 623));
        sections.add(points);
        line = new GuiLine(sections, DWL.getOut(0));
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(271, 645));
        points.add(new Point(244, 645));
        sections.add(points);
        line = new GuiLine(sections, DWH.getOut(0));
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(271, 660));
        points.add(new Point(244, 660));
        sections.add(points);
        line = new GuiLine(sections, DWL.getOut(0));
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(205, 653));
        points.add(new Point(171, 653));
        sections.add(points);
        line = new GuiLine(sections, DW.getOut(0));
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(159, 658));
        points.add(new Point(159, 664));
        sections.add(points);
        line = new GuiLine(sections, Oper1.DWout1());
        gui.addLine(line);
        
        
        sections = new ArrayList<ArrayList<Point>>();
        points = new ArrayList<Point>();
        points.add(new Point(148, 653));
        points.add(new Point(65, 653));
        sections.add(points);
        line = new GuiLine(sections, TSBDWout1.getOut(0));
        gui.addLine(line);

        // LABELE:
        gui.addLabel(new GuiLabel(475, 63, Bus1.IBUS1()));
        gui.addLabel(new GuiLabel(568, 63, TSBMOST1_2.getOut(0)));
        gui.addLabel(new GuiLabel(114, 106, TSBMOST2_1.getOut(0)));
        gui.addLabel(new GuiLabel(195, 106, Bus1.IBUS2()));
        gui.addLabel(new GuiLabel(59, 22, Bus1.IBUS1()));
        gui.addLabel(new GuiLabel(59, 382, Bus1.IBUS1()));
        gui.addLabel(new GuiLabel(59, 490, Bus1.IBUS1()));
        gui.addLabel(new GuiLabel(616, 22, Bus1.IBUS2()));
        gui.addLabel(new GuiLabel(616, 382, Bus1.IBUS2()));
        gui.addLabel(new GuiLabel(616, 490, Bus1.IBUS2()));
        gui.addLabel(new GuiLabel(240, 190, Bus1.IBUS1()));
        gui.addLabel(new GuiLabel(238, 287, MAR.getOut(0)));
        gui.addLabel(new GuiLabel(224, 413, TSBeMAR.getOut(0)));
        gui.addLabel(new GuiLabel(496, 413, TSBeMDR.getOut(0)));
        gui.addLabel(new GuiLabel(524, 127, IBUS2low.getOut(0)));
        gui.addLabel(new GuiLabel(481, 127, DBUS.getOut(0)));
        gui.addLabel(new GuiLabel(510, 203, MX1.getOut(0)));
        gui.addLabel(new GuiLabel(510, 287, MDR.getOut(0)));
        gui.addLabel(new GuiLabel(567, 317, TSBMDRout2.getOut(0)));
        gui.addLabel(new GuiLabel(525, 542, IBUS2low.getOut(0)));
        gui.addLabel(new GuiLabel(276, 637, DWH.getOut(0)));
        gui.addLabel(new GuiLabel(501, 637, DWL.getOut(0)));
        gui.addLabel(new GuiLabel(175, 647, DW.getOut(0)));
        gui.addLabel(new GuiLabel(114, 649, TSBDWout1.getOut(0)));
        
        
        
        
    }
    
    public static void addOnIBUS1(Pin pin) {
        IBUS1.setInputPin(ibus1i++, pin);
    }
    
    public static void addOnIBUS2(Pin pin) {
        IBUS2.setInputPin(ibus2i++, pin);
    }
    
    public static void addOnDBUS(Pin pin) {
        DBUS.setInputPin(dbusi++, pin);
    }
    
    public static void addOnABUS(Pin pin) {
        ABUS.setInputPin(abusi++, pin);
    }
    
    public static void addOnNOTRDBUS(Pin pin) {
        NOTRDBUS.setInputPin(rdbusi++, pin);
    }
    
    public static void addOnNOTWRBUS(Pin pin) {
        NOTWRBUS.setInputPin(wrbusi++, pin);
    }
    
    public static void addOnNOTFCBUS(Pin pin) {
        NOTFCBUS.setInputPin(fcbusi++, pin);
    }
    
    public static Pin IBUS1() {
        return IBUS1.getOut(0);
    }
    
    public static Pin IBUS2() {
        return IBUS2.getOut(0);
    }
    
    public static Pin ABUS() {
        return ABUS.getOut(0);
    }
    
    public static Pin DBUS() {
        return DBUS.getOut(0);
    }
    
    public static Pin NOTRDBUS() {
        return NOTRDBUS.getOut(0);
    }
    
    public static Pin NOTWRBUS() {
        return NOTWRBUS.getOut(0);
    }
    
    public static Pin NOTFCBUS() {
        return NOTFCBUS.getOut(0);
    }
    
    public static Pin MDR() {
        return MDR.getOut(0);
    }
    
    public static Pin MAR() {
        return MAR.getOut(0);
    }
    
    public static Pin MX1() {
        return MX1.getOut(0);
    }
    
    public static Pin TSBMOST1_2out() {
        return TSBMOST1_2.getOut(0);
    }
    
    public static Pin TSBMOST2_1out() {
        return TSBMOST2_1.getOut(0);
    }
    
    public static Pin TSBMDRoutToIBUS() {
        return TSBMDRout2.getOut(0);
    }
    
    public static Pin TSBeMDRout() {
        return TSBeMDR.getOut(0);
    }
    
    public static Pin TSBMARout() {
        return TSBeMAR.getOut(0);
    }
    
    public static Pin fcCPU() {
        return NOT1.getOut(0);
    }
    
    public static Pin hack() {
        return AND2.getOut(0);
    }
    
    public static REG RegMAR() {
        return MAR;
    }
    
    public static REG RegMDR() {
        return MDR;
    }
    
    public static REG RegDWH() {
        return DWH;
    }
    
    public static REG RegDWL() {
        return DWL;
    }
}
